<%@ page import="com.scalar.chiptrack.utils.ConfigManager,
                 com.scalar.chiptrack.commons.Constants,
                 com.scalar.chiptrack.operations.process.forms.BomPartEntryForm"%>
 <%--
  Created by IntelliJ IDEA.
  User: Murali Krishna Yengala
  Date: May 12, 2005
  Time: 10:25:54 AM
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>
<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>

<chiptrack:checkLogon sourcePage="/finishedGoodsCreateNew.do?action=new" />
<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>
<%
    String action = request.getParameter( "action" );
    action = action == null ? "" : action.trim();
    String loadType = request.getParameter("loadType");
    loadType = loadType == null ? "" : loadType.trim();
%>
<html>
    <HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
        <META http-equiv=Content-Type content="text/html; charset=windows-1252">
        <LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type="text/css" rel="stylesheet">
    </HEAD>
    <BODY bgColor="#ffffff" leftMargin="0" topMargin="0" marginheight="0" marginwidth="0" >
    <script src="<%=chipTracContext%>/jsp/includes/scripts/functions.js"></script>
    <script src="<%=chipTracContext%>/jsp/includes/scripts/validations.js"></script>
    <script src="<%=chipTracContext%>/jsp/includes/scripts/finishedGoodsPartEntry.js"></script>
    <SCRIPT language="JavaScript">

    function save()
    {
        if ( !vendorValidations(document.finishedGoodsEntryForm) )
        {
            var pa = document.getElementById("errors");
            pa.innerHTML = "<li> Please select atleast one vendor";
            return;
        }
        if ( checkValuesForBoardMaking () )
        {
            document.finishedGoodsEntryForm.approved.disabled = false;
            var cnt = document.finishedGoodsEntryForm.count.value;
            <%
                if( "confirmeditfg".equalsIgnoreCase( action ))
                {
            %>
                    var dupPartCnt = document.finishedGoodsEntryForm.dupPartsCnt.value;
                    for(var i=0;i < dupPartCnt;i++)
                    {
                        document.finishedGoodsEntryForm['equivalentPartNosList['+i+'].delete'].disabled=false;
                    }
                    document.finishedGoodsEntryForm.action = document.finishedGoodsEntryForm.action+"?action=saveEditFg";
            <%
                }
                else
                {
            %>
                    document.finishedGoodsEntryForm.action = document.finishedGoodsEntryForm.action+"?action=saveNewFg";
            <%
                }
            %>
            document.finishedGoodsEntryForm.submit();
        }
    }

    function edit()
    {
        if ( !vendorValidations(document.finishedGoodsEntryForm) )
        {
            var pa = document.getElementById("errors");
            pa.innerHTML = "<li> Please select atleast one vendor";
            return;
        }
        if ( checkValuesForBoardMaking () )
        {
            document.finishedGoodsEntryForm.approved.disabled = false;
            var cnt = document.finishedGoodsEntryForm.count.value;
            <%
                if( "confirmeditfg".equalsIgnoreCase( action ))
                {
            %>
                    var dupPartCnt = document.finishedGoodsEntryForm.dupPartsCnt.value;
                    for(var i=0;i < dupPartCnt;i++)
                    {
                        document.finishedGoodsEntryForm['equivalentPartNosList['+i+'].delete'].disabled=false;
                    }
                    document.finishedGoodsEntryForm.action = document.finishedGoodsEntryForm.action+"?action=edit";
            <%
                }
                else
                {
            %>
                    document.finishedGoodsEntryForm.action = document.finishedGoodsEntryForm.action+"?action=edit";
            <%
                }
            %>
            document.finishedGoodsEntryForm.submit();
        }
    }
    </script>
    <!-- Top Header Start-->
    <%@ include file="/jsp/includes/header.jsp" %>
    <!-- Top Header End-->
    <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
      <TBODY >
      <TR>
        <TD width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>

        <!-- Side Navigation start -->
        <%@ include file="/jsp/operations/product_menu.jsp" %></TD>
        <!-- end of the side navigations -->

        <TD bgcolor="#ffffff">
        <IMG height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8></TD>
        <TD bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></TD>
        <TD valign="top" width="100%">

        <IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border=0>
        <BR>
        <!-- from here your body starts -->
        <html:form action="/finishedGoodsEntry" name="finishedGoodsEntryForm" type="com.scalar.chiptrack.operations.finishedGoods.forms.FinishedGoodsEntryForm">
            <TABLE width='95%' align=right cellpadding='3' cellspacing='2' border='0' bordercolor='black'>
                <%--todo change the following heading if necessary--%>
                <TR><Td colspan='4' class="NArialW" align=center>
                <%   if( "view".equalsIgnoreCase(loadType)) {  %>
                        View Finished Goods
                <%   } else {%>
                        Confirm Finished Goods
                <%}%>
                </td></tr>
                <%   if( !("view".equals(loadType))) {  %>
                <TR><TD colspan='4'><IMG src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height='10'></TD></TR>
                 <TR>
                    <td colspan='3' class='NArialL' align='right'><font color="red">Are you sure, you want to confirm this Finished Goods &nbsp;&nbsp;</font></td>
                    <TD align='center'>
                        <A href="javascript:save();" ><img border="0" src="<%=chipTracContext%>/jsp/includes/images/confirm.gif" onmouseover="window.status='Click here to Confirm this Finished Goods';return true" onmouseout="window.status='';return true" title="Click here to Confirm"></A>&nbsp;&nbsp;&nbsp;
                        <A href="javascript:edit();" onMouseOver="window.status='Click here to edit this Finished Goods';return true" onMouseOut="window.status='';return true" title="Click here to Edit"><IMG border=0 src="<%=chipTracContext%>/jsp/includes/images/edit.gif"></a>
                     </TD>
                  </TR>
                  <% } %>
                <tr><td colspan='4' align="left" class='NArialL'>&nbsp;<FONT id="errors" color='FF0000'></font></td></tr>
                <TR><TD colspan='4'><chiptrack:errors styleClass="NArialL"/></TD></TR>
                <TR><TD colspan='4'><chiptrack:info styleClass="NArialL"/></TD></TR>
                <TR>
                    <TD class='NArialL'> Base Product : </TD>
                    <TD class="NArialL">
                        <html:text name="finishedGoodsEntryForm" property="baseProductNo" size='25' styleClass="txfield" disabled="true"/>
                    </TD>
                    <TD class='NArialL' nowrap>
                        <logic:present name="fgiProductsList">
                            FGI Part Number :
                        </logic:present>
                    </TD>
                    <TD class="NArialL"  width='25%'>
                        <logic:present name="fgiProductsList">
                            <html:select property="fgiProcessStepIds" name="finishedGoodsEntryForm" styleClass="txfield"  multiple="true" size="6" disabled="true">
                            <html:options collection="fgiProductsList" property="value" labelProperty="label"/>
                            </html:select>
                        </logic:present>
                    </TD>
                </TR>
                <TR>
                    <TD class='NArialL' width='25%'> Process Name : </TD>
                    <TD class="NArialL" width='25%'>
                        <html:text name="finishedGoodsEntryForm" property="baseProcessType" size='25' styleClass="txfield" disabled="true"/>
                    </TD>
                    <TD class='NArialL' width='25%' nowrap> Customer Name : </TD>
                    <TD class="NArialL" width='25%'>
<%--                    <html:text name="finishedGoodsEntryForm" property="customerName" size='25' styleClass="txfield" disabled="true"/>--%>
                        <html:select property="customerIds" name="finishedGoodsEntryForm" styleClass="txfield" multiple="true" size="6" disabled="true">
                        <html:options collection="customersList" property="value" labelProperty="label"/>
                        </html:select>
                    </TD>
                </TR>
                <TR>
                    <TD class='NArialL' nowrap> OPN / Mktg Part Number : </TD>
                    <TD class="NArialL">
                        <html:text name="finishedGoodsEntryForm" property="finishedGoodsPartNo" size='25' styleClass="txfield" disabled="true"/>
                    </TD>
                    <TD class='NArialL'> Program Code : </TD>
                    <TD class='NArialL'>
                        <html:text name="finishedGoodsEntryForm" property="programCode" size='25' styleClass="txfield" disabled="true"/>
                    </TD>

                </TR>
                <TR>
                    <TD class='NArialL'> Is Approved : </TD>
                    <TD class="NArialL">
                        <html:checkbox name="finishedGoodsEntryForm" property="approved" styleClass="txfield"  disabled="true"/>
                    </TD>
                    <TD class='NArialL'> CRC Code : </TD>
                    <TD class="NArialL">
                        <html:text name="finishedGoodsEntryForm" property="crc" styleClass='txField' size='25' disabled='true'/>
                    </TD>
                </TR>
                <TR>
                    <TD class='NArialL'> Description : </TD>
                    <TD class="NArialL">
                        <html:textarea name="finishedGoodsEntryForm" property="description" styleClass='txfield' cols='25' rows='6' disabled="true"/>
                    </TD>
                    <TD class='NArialL'> Algorithm : </TD>
                    <TD class='NArialL'>
                        <html:select styleClass='txfield' property='algorithm' disabled='true'>
                            <html:option value='-1'>Select Algorithm</html:option>
                            <html:option value='-2'>Add Algorithm</html:option>
                            <html:option value='-3'>----------------</html:option>
                            <html:option value="-4">&nbsp;</html:option>                            
                            <html:options collection="algorithmList" property="value" labelProperty="label"/>
                        </html:select>
                    </TD>
                </TR>
                <TR>
                    <TD class='NArialL'> Is Blank Product : </TD>
                    <TD class="NArialL">
                        <html:select property="isBlankProduct" styleClass="txfield" disabled="true">
                            <html:option value=""></html:option>
                            <html:option value="0">Yes</html:option>
                            <html:option value="1">No</html:option>
                        </html:select>
                    </TD>
                    <TD class='NArialL'> </TD>
                    <TD class='NArialL'> </TD>
                </TR>
                <TR><TD colspan='4'>
                    <IMG src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height='20'>
                </TD></TR>
                 <TR><TD colspan='4'>
                    <table width="48%" border='0'>
                        <tr><td class="NArialL" height="18" colspan='2'> Equivalent OPN :</td></tr>
                        <% int dupPartsCnt = 0;%>
                        <logic:present property="equivalentPartNosList" name="finishedGoodsEntryForm">
                            <tr>
                                <% if( "confirmeditfg".equalsIgnoreCase(action)){ %>
                                    <td width='20%' align="center" bgcolor="#993333" height="1"><font class="NArialL"><font color="#FFFFFF">Delete</font></td>
                                <%  } %>
                                <td width='100%' align="center" bgcolor="#993333" height="1"><font class="NArialL"><font color="#FFFFFF">OPN</font></td>
                            </tr>
                            <nested:iterate name="finishedGoodsEntryForm" property="equivalentPartNosList" id="equivalentPart" type="com.scalar.chiptrack.operations.finishedGoods.EquivalentPartNumber">
                            <tr>
                                <% if( "confirmeditfg".equalsIgnoreCase(action)){ %>
                                    <td align="center" bgcolor="#DEE1E2">
                                    <nested:checkbox name="equivalentPart" property="delete" styleClass="txfield" disabled="true"/>
                                    </td>
                                <%  } %>
                                <td align="center" bgcolor="#DEE1E2">
                                <nested:text name="equivalentPart" property="partNo" size='25' styleClass="txfield" disabled="true"/>
                                </td>
                            </tr>
                            <% dupPartsCnt ++;%>
                            </nested:iterate>
                        </logic:present>
                        <logic:notPresent property="equivalentPartNosList" name="finishedGoodsEntryForm">
                            <tr></tr><td colspan='2' align="left" class='NArialL'><FONT id="errors" color='green'>No Duplicate OPNs were defined</font></td></tr>
                        </logic:notPresent>
                        <input type="hidden" name="dupPartsCnt" value="<%=dupPartsCnt%>">
                    </table>
                </td>
                </tr>
                 <TR><TD colspan='4'>
                    <table width="70%" border='0'>
                    <logic:present property="parametersList" name="finishedGoodsEntryForm">
                        <tr><td class="NArialL" height="18" colspan=3> System Parameters :</td></tr>
                        <tr>
                            <td width="33%" align="center" bgcolor="#993333" height="1"><font class="NArialL"><font color="#FFFFFF">Parameter</font></td>
                            <td width="33%" align="center" bgcolor="#993333" height="1"><font class="NArialL"><font color="#FFFFFF">Units</font></td>
                            <td width="33%" align="center" bgcolor="#993333" height="1"><font class="NArialL"><font color="#FFFFFF">Value</font></font></td>
                        </tr>
                        <nested:iterate name="finishedGoodsEntryForm" property="parametersList" id="parametersList" type="com.scalar.chiptrack.operations.processtypesetup.ProcessParameters">
                            <tr>
                                <td align="center" bgcolor="#DEE1E2">
                                    <nested:text property="paramName" styleClass="txfield" disabled="true" />
                                </td>
                                <td align="center" bgcolor="#DEE1E2" height="1">
                                    <nested:text property="paramUnit" styleClass="txfield" disabled="true" />
                                </td>
                                <td align="center" bgcolor="#DEE1E2" height="1">
                                    <nested:text property="paramVal" styleClass="txfield"  disabled="true" />
                                </td>
                            </tr>
                        </nested:iterate>
                    </logic:present>
                    <logic:notPresent  property="parametersList" name="finishedGoodsEntryForm">
                        <tr><td colspan='4' align="left" class='NArialL'><FONT id="errors" color='FF0000'>No System Parameters were found for this process type</font></td></tr>
                    </logic:notPresent>
                    </table>
                </td>
                </tr>
                 <br>
                 <TR><TD colspan='4'>
                    <table width="70%" border='0'>
                        <tr><td class="NArialL" height="18" colspan=3>Vendor Location Information :</td></tr>
                        <tr>
                            <td width="13%" align="center" bgcolor="#993333" height="1"><font class="NArialL"><font color="#FFFFFF">Select</font></td>
                            <td width="13%" align="center" bgcolor="#993333" height="1"><font class="NArialL"><font color="#FFFFFF">Priority</font></td>
                            <td width="74%" align="center" bgcolor="#993333" height="1"><font class="NArialL"><font color="#FFFFFF">Location</font></font></td>
                        </tr>
                        <%int idd = 0;%>
                        <logic:iterate name="finishedGoodsEntryForm" property="vendorList" id="vendors" type="com.scalar.chiptrack.operations.process.VendorLocation" indexId="chkCount">
                            <tr>
                                <td width="20%" align="center" bgcolor="#DEE1E2"
                                height="1"><font class="NArialL">
                                <font color="#FFFFFF">
                                <html:checkbox name="vendors" property="select" styleClass="txfield" disabled="true"/>
                                </font></font></td>
                                <td width="20%" align="center" bgcolor="#DEE1E2" height="1">
                                <font class="NArialL" color="#FFFFFF">
                                <logic:equal name="vendors" property="select" value="on">
                                <html:text name="vendors" property="priority" size="6" maxlength="4" styleClass="txfield" disabled="true" />
                                </logic:equal>
                                <logic:notEqual name="vendors" property="select" value="on">
                                <html:text name="vendors" property="priority" size="6" maxlength="4" styleClass="txfield" value="" disabled="true" />
                                </logic:notEqual>
                                </font></td>
                                <td width="60%" align="center" bgcolor="#DEE1E2" height="1"><font class="NArialL"><font color="#FFFFFF">
                                    <html:text name="vendors" property="locationName" disabled="true" size='40' styleClass="txfield" />
                                    <html:hidden name="vendors" property="locationID" />
                                </font></font></td>
                            </tr>
                        <% idd++; %><!--Very important please dont delete.-->
                        </logic:iterate>
                    </table></TD>
                 </TR>
                 </TABLE>
                 </TD></TR>
                <TR><TD colspan='4'><IMG src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height='10'></TD></TR>
                 <input type="hidden" name="count" value="<%=idd%>">
                </TABLE>
            </table>
        </html:form>
        <!-- till here -->
        </TD>
        <TD bgcolor="#ffffff"><IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=1></TD>
        </TR>
        </TABLE>
        <!-- Footer starts here -->
        <%@ include file="/jsp/includes/footer.jsp" %>
        <!-- footer end here -->
    </body>
</html>